package homework;

import java.util.List;

public class Homework_P1M3_4_DeleteStudent {
    /**
     * 通过学号删除学生对象
     * 
     * @param id 学号
     * @param listStudents 
     */
    public static void Homework_P1M3_4_DeleteStudent(int id, List<Homework_P1M3_4_Student> listStudents) {
      	// 遍历学生对象List
        for (Homework_P1M3_4_Student student : listStudents) {
          	// 获取当前对象索引
            int index = listStudents.indexOf(student);
          	// 如果当前对象id等于目标id
            if (id == student.getId()) {
              	// 删除
                listStudents.remove(index);
                System.out.printf("%d删除成功\n", student.getId());

            }
        }

    }
}

